package ar.com.mindset.geometrics.effects {
	import ar.com.mindset.geometrics.MapItem;
	import ar.com.mindset.geometrics.RegionsEffectStrategy;

	import mx.effects.AnimateProperty;
	import mx.effects.CompositeEffect;
	import mx.effects.Effect;
	import mx.effects.Fade;
	import mx.effects.Parallel;
	import mx.effects.Sequence;

	public class FadeOutEffectStrategy implements RegionsEffectStrategy {

		public function createEffect(regions:Array):Effect {
			var retVal:CompositeEffect=new Parallel();
			for (var i:Number=0; i < regions.length; i++) {
				var region:MapItem=regions[i];
				retVal.addChild(getEffect(region));
			}

			retVal.duration=1000;
			return retVal;
		}

		private function getEffect(target:Object):Effect {
			var retVal:Sequence=new Sequence();
			var fadeOut:Fade=new Fade();
			fadeOut.alphaFrom=1;
			fadeOut.alphaTo=0;

			retVal.addChild(fadeOut);

			retVal.target=target;
			return retVal;
		}

		public function toString():String {
			return "Fade Out";
		}

	}
}